<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Password_change extends MX_Controller {

	public function __construct() {
		parent::__construct();
		
		$this->template
		->set_layout('default') // application/views/layouts/two_col.php
		->set_theme('admin'); // application/views/layouts/two_col.php
			
		
		
		$this->load->model('admin_member_model');
		
		$this->admin_member_model->check_admin_login();
		
		
		$this->template->set_partial('nav_bar', 'layouts/nav_bar');
		$this->template->set_partial('side_menu', 'layouts/side_menu');
		$this->template->set_partial('footer','footer/footer');
		
	}
	
	public function index(){
		
		//die("Controller Running ok...");
		$this->template->build('member/password_change');
		
	}
	
	function submit()
	{
		//if ($this->input->post('verify')) {
			
			
			
			$this->form_validation->set_rules('adminoldPsswrd', 'Old Password', 'xss_clean');
			$this->form_validation->set_rules('adminnwPsswrd', 'New Password', 'xss_clean');
			$this->form_validation->set_rules('admincnfrmPsswrd', 'Confirm Password', 'xss_clean|matches[adminnwPsswrd]');
				
			if ($this->form_validation->run() == TRUE) {
				
				if (get_session('sess_admin_password') == trim($this->input->post('adminoldPsswrd'))) {
					$data=array(
							'password'=>$this->input->post('adminnwPsswrd'));
					 
				//	var_dump($data);die();
					
					$this->db->where('id',get_session('sess_admin_id'));
					$this->db->update('member',$data);
					$this->session->set_flashdata('message', 'Password Changed Sucessfully Login with new Password....!');
					redirect('secure/member/password_change');
		
				} else {
					$this->session->set_flashdata('message', 'Old password is wrong!');
					redirect('secure/member/password_change');
				}
			} else {
				$this->session->set_flashdata('message', 'Field is empty or new password is mismatched with confirm password! ');
				redirect('secure/member/password_change');
			}
	//	}
		}
	
	
}	
/* End of file*/	